package com.lqq.controller;

import com.lqq.entity.User;
import com.lqq.mock.UserConst;
import com.lqq.service.UserService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * TODO 使用swagger显示所有接口
 * @author lqq
 * @date 2018/12/6
 */
@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserService userService;

    //增删改查

    @GetMapping("/list")
    public List<User> list(){
        return userService.findList();
    }

    @PostMapping("/queryByExample")
    @ApiOperation(value = "根据Example查询")
    public List<User> queryByExample(){
        return userService.findByExample();
    }

    @ApiOperation(value = "根据姓名查询")
    @RequestMapping(value = "/findByName",method = RequestMethod.POST)
    public List<User> findByName(){
        return userService.findByName(UserConst.NAMES[0]);
    }

}
